use std::iter::Map;
use std::collections::*;

fn move_map() {
    let m: Map<i32, String>;
    for p in [("a", 12), ("b", 16)].into_iter().map(|x| {
        println!("x= {:?} y={:?}", &x.0, &x.1)
    }) {
        print!("{:?}", p);
    }

    let mut hs: HashMap<i32, String> = HashMap::new();
    hs.insert(12, "java".to_string());
    hs.insert(13, "jsp".to_string());
    let t = hs.get(&13);
    match t {
        None => {
            print!("no found key ");
        }
        Some(t) => {
            print!("{}\n", t);
        }
    }
    hs.entry(16).or_insert("php".to_string());

    print!("{}", hs.len());


    let s = "hello world from world";
    let mut st = s.split_whitespace();
    let mut mt: HashMap<String, i32> = HashMap::new();
    for i in st.into_iter() {
        let idx: &mut i32 = mt.entry(i.to_string()).or_insert(0);
        *idx += 1;
    }
    println!("{:?}", mt)
}

fn main() {
    move_map();
}
